package easyway.trainapp.webframework.util;

import   java.util.*; 
/**
*
* @author zhangqihang
* @date Nor 23, 2009
*/
public   class   RandomUtil{ 
	//在n的范围内，随机生成j个不重复随机数
    public int[] randomm(int j,int n){
        LinkedList <Integer>   myList=   new   LinkedList <Integer> (); 
        for(int   i=0;i <n;i++) 
                myList.add(i+1); 
        int[] arr = new int[j]; 
        for(int   i=0;i <arr.length;i++){ 
            arr[i]=myList.remove((int)(Math.random()*n)); 
            n--; 
        } 
		return arr; 
    }
        
    public   static   void   main(String[]   args) {
    	RandomUtil util=new  RandomUtil();
    	int[]   arr  =util.randomm(5,6);
    	for(int   i=0;i <arr.length;i++) 
        { 
                System.out.print(arr[i]+"   "); 
        }
    }
        
}
